
import 'package:dio/dio.dart';

import 'networkHelper.dart';

final apiManager = ApiManager();

class ApiManager {

  /// 用于gitee API的请求
  static String get gitUrl {
    return 'https://gitee.com/api/v5/repos/kamisato-nobitta/tool-box';
  }

  Map<String, dynamic> gitAccessToken = {
    'access_token': '1b91d57119f3ca6b5b231160126b589b'
  };

  Future<Response> getGitReleasesLatestInfo() async {
    return await _handleGiteeApi(url: '/releases/latest');
  }

  Future<Response> getRepoInfo() async {
    return await _handleGiteeApi();
  }

  Future<Response> _handleGiteeApi({String url = '', Map<String, dynamic>? data}) async {
    return await HttpUtil().get('$gitUrl$url', data: {...gitAccessToken, ...?data});
  }
}
